package hivi.vn.hivigold.activities;

import hivi.vn.hivigold.R;
import hivi.vn.hivigold.fragment.PartnerFragment;
import hivi.vn.hivigold.fragment.PartnerFragment.PartnerListener;
import hivi.vn.hivigold.objects.Partner;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.Window;

public class SelectPartner extends FragmentActivity implements PartnerListener {
	public static final String SELECTED_PARTNER = "SELECTEDPARTNER";
	public static final int SELECTED_PARTNER_KEY = 1;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.selectpartner);
		PartnerFragment partner = new PartnerFragment();
		partner.setListener(this);
		FragmentManager fm= getSupportFragmentManager();
		fm.beginTransaction().replace(R.id.fragment1,partner).commit();
	}

	@Override
	public void partnerSelected(Partner p) {
		// TODO Auto-generated method stub
		Intent i = new Intent();
		Bundle bundle = new Bundle();
		bundle.putSerializable(SELECTED_PARTNER, p);
		i.putExtras(bundle);
		setResult(RESULT_OK, i);
		finish();
	}
}
